/*
 * Created on 03/06/2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package br.ufal.tci.nexos.arcolive.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

/**
 * @author Marcio
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ServicesManager extends JInternalFrame {
	
	private JPanel mainPanel;
	private JPanel upPanel;
	private JPanel downPanel;
	
	private JList servicesList;
	private JScrollPane listScroll;
	private JPanel buttonsPanel;
	private JButton buttonAdd;
	private JButton buttonRemove;
	private JButton buttonUsers;

	private JLabel servicesLabel;
	private JComboBox servicesCombo;
	private JButton playButton;
	private JButton pauseButton;
	private JButton stopButton;

	public ServicesManager() {
		initComponents();
	}
	
	public void initComponents() {
		mainPanel = new JPanel();
		
		setIconifiable(true);
		setClosable(true);
        //setTitle("Gerenciamento de Servi?os");
		setTitle("Services Management");
		
		upPanel = new JPanel();
		downPanel = new JPanel();
		
		//servicesLabel = new JLabel("Servi?o: ");
		servicesLabel = new JLabel("Service: ");
		
		servicesCombo = new JComboBox();
		servicesCombo.setPreferredSize(new Dimension(225,20));
		
		playButton = new JButton(new ImageIcon(ServicesManager.class.getResource("icons/Play.png")));
		playButton.setPreferredSize(new Dimension(19, 19));
		
		pauseButton = new JButton(new ImageIcon(ServicesManager.class.getResource("icons/Pause.png")));
		pauseButton.setPreferredSize(new Dimension(19, 19));
		
		stopButton = new JButton(new ImageIcon(ServicesManager.class.getResource("icons/Stop.png")));
		stopButton.setPreferredSize(new Dimension(19, 19));
		
		upPanel.setLayout(new FlowLayout());
		upPanel.add(servicesLabel);
		upPanel.add(servicesCombo);
		upPanel.add(playButton);
		upPanel.add(pauseButton);
		upPanel.add(stopButton);
		
		servicesList = new JList(new DefaultListModel());
		servicesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		
		listScroll = new JScrollPane(this.servicesList);
		
		buttonAdd = new JButton(new ImageIcon(ServicesManager.class.getResource("icons/Adicionar.png")));
		buttonAdd.setPreferredSize(new Dimension(19, 19));
		
		buttonRemove = new JButton(new ImageIcon(ServicesManager.class.getResource("icons/Remover.png")));
		buttonRemove.setPreferredSize(new Dimension(19, 19));

		buttonUsers = new JButton(new ImageIcon(ServicesManager.class.getResource("icons/Usuarios.png")));
		buttonUsers.setPreferredSize(new Dimension(19, 19));
		buttonUsers.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				new UsersManager();
			}
		});
		
		buttonsPanel = new JPanel();
		buttonsPanel.setLayout(new GridLayout(6,1));
		buttonsPanel.add(this.buttonAdd);		
		buttonsPanel.add(this.buttonRemove);
		buttonsPanel.add(this.buttonUsers);
		
		downPanel.setPreferredSize(new Dimension(400,150));
		downPanel.setLayout(new BorderLayout());
		downPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), " Inst?ncias do Servi?o: "));
		downPanel.add(listScroll, BorderLayout.CENTER);
		downPanel.add(buttonsPanel, BorderLayout.WEST);
		
		mainPanel.add(upPanel, BorderLayout.NORTH);
		mainPanel.add(downPanel, BorderLayout.CENTER);

		/* Para o print screen */
		
		//servicesCombo.addItem("LVS Confer?ncia");
		//servicesCombo.addItem("LVS Bate Papo");
		//servicesCombo.addItem("LVS Compartilhamento de Arquivo");
		//servicesCombo.addItem("LVS Quadro Branco");
		//servicesCombo.addItem("LVS Captura de Tela");
		
		servicesCombo.addItem("ArCoLIVE Conference");
		servicesCombo.addItem("ArCoLIVE Chat");
		servicesCombo.addItem("ArCoLIVE Files share");
		servicesCombo.addItem("ArCoLIVE Whiteboard");
		servicesCombo.addItem("ArCoLIVE Screen Capture");
		
		//((DefaultListModel)servicesList.getModel()).addElement("Confer?ncia da Comunidade Programa??o 2");
		//((DefaultListModel)servicesList.getModel()).addElement("Aula de Intelig?ncia Artificial 1");
		//((DefaultListModel)servicesList.getModel()).addElement("Palestra sobre Engenharia de Software");
		//((DefaultListModel)servicesList.getModel()).addElement("Semin?rio sobre JavaServer Faces");
		
		((DefaultListModel)servicesList.getModel()).addElement("Conference about computer programming");
		((DefaultListModel)servicesList.getModel()).addElement("Artificial Inteligence class");
		((DefaultListModel)servicesList.getModel()).addElement("Lecture about Software Engeneering");
		((DefaultListModel)servicesList.getModel()).addElement("Lecture about JavaServer Faces");
		
		/* fim */
		
		getContentPane().add(mainPanel);
		
        pack();
        Desktop.getInstance().getDesktopPane().add(this);
		setSize(450, 240);
		show();
	}

}